import { editor } from "@codingame/monaco-editor";
import { updateEditorKeybindingsMode } from "@codingame/monaco-editor-wrapper";
import { Extension } from "../ExtensionManager";
import { FileManager } from "../FileManager";
export const KeyBind: Extension = () => {
    return {
        name: "keybind",
        setup(this: FileManager, ed: editor.IStandaloneCodeEditor) {
            const status = this.statusBar.addStatus("key_mode");
            status.textContent = "Classic";
            status.title = "KeyBind Mode";
            (["Vim", "Classic", "Emacs"] as const).forEach((mode) => {
                ed.addAction({
                    id: "key_mode_" + mode,
                    label: "KeyBind: " + mode,
                    contextMenuGroupId: "KeyMode",
                    run: () => {
                        status.textContent = mode;
                        updateEditorKeybindingsMode(
                            ed,
                            mode.toLowerCase() as any,
                            status
                        );
                    }, // 点击后执行的操作
                });
            });
        },
    };
};
